import { reactive } from 'vue'
import { VxeGridProps } from 'vxe-table'

interface Rows {
  idNo: string
  secretsName: string
  secretsType: string
  date: string
  inventor: string
  unit: string
  submitDate: string
}

const selectOptions = reactive([
  {
    label: '博士',
    value: '0',
  },
  {
    label: '硕士',
    value: '1',
  },
  {
    label: '学士',
    value: '2',
  },
])

const selectMajorOptions = reactive([
  {
    label: '正高',
    value: '0',
  },
  {
    label: '副高',
    value: '1',
  },
])

const selectExpertCategory = reactive([
  {
    label: '中国国家科学院院士',
    value: '0',
  },
  {
    label: '中国工程院院士',
    value: '1',
  },
  {
    label: '双院士',
    value: '2',
  },
  {
    label: '长江学者',
    value: '3',
  },
  {
    label: '新世纪及跨世纪优秀人才',
    value: '4',
  },
  {
    label: '百千万人才工程一二层次入选者',
    value: '5',
  },
  {
    label: '中科院百人计划入选者',
    value: '6',
  },
  {
    label: '国家杰出青年基金获得者',
    value: '7',
  },
  {
    label: '国家有突出贡献专家',
    value: '8',
  },
  {
    label: '全军有突出贡献专家',
    value: '9',
  },
  {
    label: '其它',
    value: '10',
  },
])

const politicalStatus = reactive([
  {
    label: '中国共产党党员',
    value: '0',
  },
  {
    label: '中国共产党预备党员',
    value: '1',
  },
  {
    label: '中国国民党革命委员会会员',
    value: '2',
  },
  {
    label: '中国民主同盟盟员',
    value: '3',
  },
  {
    label: '中国民主建国会会员',
    value: '4',
  },
  {
    label: '中国农工民主党党员',
    value: '5',
  },
  {
    label: '中国致公党党员',
    value: '6',
  },
  {
    label: '九三学社社员',
    value: '7',
  },
  {
    label: '群众',
    value: '8',
  },
])

const politicalAffiliationFormater = (
  politicalAffiliation: number | string
): string => {
  return politicalStatus.filter((item) => item.value == politicalAffiliation)[0]
    ?.label
}

const expertTypeFormater = (expertType: number | string): string => {
  return selectExpertCategory.filter((item) => item.value == expertType)[0]
    ?.label
}

const technicalPositionFormater = (
  technicalPosition: number | string
): string => {
  return selectMajorOptions.filter((item) => item.value == technicalPosition)[0]
    ?.label
}

const gridOptions = reactive<VxeGridProps<any>>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  columns: [
    { title: '序号', type: 'seq', width: 50 },
    { field: 'id', title: '专家编号' },
    { field: 'name', title: '专家姓名' },
    {
      field: 'gender',
      title: '性别',
      slots: {
        default: 'gender_default',
      },
    },
    { field: 'birthDate', title: '出生年月' },
    {
      field: 'politicalAffiliation',
      title: '政治面貌',
      slots: { default: 'politicalAffiliation_default' },
    },
    { field: 'mobile', title: '联系电话' },
    { field: 'unitName', title: '单位名称' },
    {
      field: 'expertType',
      title: '专家类别',
      slots: { default: 'expertType_default' },
    },
    {
      field: 'technicalPosition',
      title: '专家技术职务',
      slots: { default: 'technicalPosition_default' },
    },
    {
      field: 'majorStudyOne',
      title: '主研方向',
      slots: { default: 'majorStudy' },
    },
    { title: '操作', width: 200, slots: { default: 'operate' } },
  ],
  data: [
    {
      idNo: 'xxx',
      name: 'xxxx',
      sex: '1',
      birthday: '2023-01-01 00:00:00',
      phone: '177xx',
      unitName: 'xxxxx',
      submitDate: 'xxx',
    },
  ],
})

const descriptions = reactive([
  {
    label: '技术秘密名称:',
    value: 'secretsName',
  },
  {
    label: '完成单位:',
    value: 'unit',
  },
  {
    label: '申请日期:',
    value: 'date',
  },
])

const operationLog = reactive<VxeGridProps>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  columns: [
    { field: 'type', title: '操作类型', width: 200 },
    { field: 'name', title: '操作员', width: 200 },
    { field: 'content', title: '操作内容' },
    { field: 'date', title: '操作时间', width: 200 },
  ],
  toolbarConfig: {
    slots: {
      buttons: 'toolbar_buttons',
    },
  },
  data: [
    {
      type: '修改状态',
      name: '曲丽丽',
      content: '修改了“软件名称”',
      date: '2023-01-01 00:00:00',
    },
    {
      type: '新增信息',
      name: '周毛毛',
      content: '新增软著信息',
      date: '2023-01-01 00:00:00',
    },
  ],
})

const patentPeople = reactive<VxeGridProps>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  editConfig: {
    // trigger: 'manual',
    // mode: 'row',
    // showStatus: true,
  },
  columns: [
    { title: '序号', type: 'seq', width: 50 },
    {
      field: 'patentName',
      title: '姓名',
      editRender: { autofocus: '.vxe-input--inner' },
      slots: { edit: 'patentName_edit' },
    },
    {
      field: 'patentPhone',
      title: '手机号',
      editRender: { autofocus: '.vxe-input--inner' },
      slots: { edit: 'patentPhone_edit' },
    },
    {
      field: 'patentType',
      title: '员工编号',
      editRender: { autofocus: '.vxe-input--inner' },
      slots: { edit: 'patentType_edit' },
    },
    {
      field: 'date',
      title: '贡献率',
      editRender: { autofocus: '.vxe-input--inner' },
      slots: { edit: 'date_edit' },
    },
    { title: '操作', width: 300, slots: { default: 'operate' } },
  ],
  toolbarConfig: {},
  data: [
    {
      patentName: 'xxx',
      patentPhone: '177xxxxxxx',
      patentType: '233xxx',
      date: '10',
    },
  ],
})

const detailsDescriptions = reactive({
  basicPersonnel: [
    {
      label: '专家名称:',
      value: 'name',
    },
    {
      label: '性别:',
      value: 'gender',
    },
    {
      label: '出生年月:',
      value: 'birthDate',
    },
    {
      label: '政治面貌:',
      value: 'politicalAffiliation',
    },
    {
      label: '联系电话:',
      value: 'mobile',
    },
  ],
  expertPersonnel: [
    {
      label: '最高学位:',
      value: 'highestDegree',
    },
    {
      label: '专业技术职务:',
      value: 'technicalPosition',
    },
    {
      label: '专家类别:',
      value: 'expertType',
    },
    {
      label: '主研方向1:',
      value: 'majorStudyOne',
    },
    {
      label: '主研方向2:',
      value: 'majorStudyTwo',
    },
    {
      label: '主研方向3:',
      value: 'majorStudyThree',
    },
    {
      label: '单位名称:',
      value: 'unitName',
    },
  ],
})

export {
  gridOptions,
  descriptions,
  operationLog,
  patentPeople,
  selectOptions,
  selectMajorOptions,
  selectExpertCategory,
  detailsDescriptions,
  politicalStatus,
  politicalAffiliationFormater,
  expertTypeFormater,
  technicalPositionFormater,
}
